package org.springblade.modules.client;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.modules.course.entity.CourseCommentEntity;
import org.springblade.modules.course.service.CourseCommentService;
import org.springblade.modules.course.vo.CourseCommentVO;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 客户端 课程评价控制器
 */
@RestController
@AllArgsConstructor
@RequestMapping("blade-client/course-comment")
@Api(value = "客户端课程评价相关接口", tags = "课程评价相关接口")
public class ClientCourseCommentController {

	private final CourseCommentService courseCommentService;


	/**
	 * 课程评价列表 分页
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "课程评价列表分页", notes = "传入必要参数")
	public R<IPage<CourseCommentVO>> list(CourseCommentVO entity, Query query) {
		IPage<CourseCommentVO> pages = courseCommentService.selectCourseCommentPage(Condition.getPage(query),entity );
		return R.data(pages);
	}


	/**
	 * 课程评价 新增
	 */
	@PostMapping("/save")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "新增", notes = "传入必要参数")
	public R save(@Valid @RequestBody CourseCommentEntity entity) {
		return R.status(courseCommentService.save(entity));
	}
}
